<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>  
<c:set var="ctx" value="${pageContext.request.contextPath }" />
<link rel="stylesheet"
	href="${ctx }/resources/js/select2/select2.min.css" />
<script type="text/javascript"
	src="${ctx }/resources/js/select2/select2.min.js"></script>
<script type="text/javascript"
	src="${ctx }/resources/js/select2/zh-CN.js"></script>
	<script type="text/javascript">
$(function() {
	
	 webside.form.retype.retypeForm(); 
})
</script>
<script src="${ctx }/resources/js/upload/ajaxfileupload.js"
	type="text/javascript"></script>
<script type="text/javascript">
$(function() {
	
});

</script>

<style>
.iconShow
{
	padding-left: 10px; 
	padding-top: 3px;
}
.source-icon
{
	 width:95%;
	 float:left;
}
@media screen and (max-width: 374px){
	.source-icon
	{
		 width:82%;
	}
}
@media screen and (min-width: 375px) and (max-width: 449px){
	.source-icon
	{
		 width:85%;
	}
}
@media screen and (min-width: 450px) and (max-width: 1279px) {
	.source-icon
	{
		 width:90%;
	}
}
@media screen and (min_width: 1280px) {
	.source-icon
	{
		 width:90%;
	}
}
</style>
<div class="page-header">
	<h1>
		<c:if test="${empty retype}">
		新增匹配
		</c:if>
		<c:if test="${!empty retype}">
		编辑匹配
		</c:if>
	</h1>
</div>
<div class="row" style="margin-top: 5px;">
	<div class="col-xs-12">
		<form id="retypeForm" name="retypeForm" class="form-horizontal"  role="form" method="post">
			  <c:if test="${!empty retype}">
				<%-- <input type="hidden" id="pageNum" name="pageNum" value="${page.pageNum }"> 
				<input type="hidden" id="pageSize" name="pageSize" value="${page.pageSize }"> 
				<input type="hidden" id="orderByColumn" name="orderByColumn" value="${page.orderByColumn }"> 
				<input type="hidden" id="orderByType" name="orderByType" value="${page.orderByType }"> --%>
				<input type="hidden"  id='id' name="id" value="${retype.id }">
			</c:if>  
			<div class="form-group">
				<label class="control-label col-sm-2 no-padding-right" for="source">来源</label>
				<div class="col-sm-8">
				<div class="clearfix">
					<%-- <input class="form-control" name="source" id="source" type="text"
						value="${retype.source}" placeholder="来源" /> --%>
					<select id="source" class="form-control" name='source' <c:if test="${retype.source ne null}">disabled="disabled"</c:if>>
							<option class="ch" value=""
								<c:if test="${retype.source eq null}">selected="selected"</c:if>>请选择</option>
							<c:forEach items="${list_source}" var="t">
								<option class="ch" value="${t.name}" <c:if test="${retype.source eq t.name}"> selected="selected"</c:if> >${t.name}</option>
							</c:forEach>
						</select>
                </div>
				</div>
            </div>
           <%--  <div class="form-group">
				<label class="control-label col-sm-1 no-padding-right" for="name">来源类型编码</label>
				<div class="col-sm-10">
				<div class="clearfix">
					<input class="form-control" name="sourceChannelCode" id="sourceChannelCode" type="text"
						value="${retype.sourceChannelCode }" placeholder="编码" />
                </div>
				</div>
            </div> --%>
            <div class="form-group">
				<label class="control-label col-sm-2 no-padding-right" for="channel">来源频道</label>
				<div class="col-sm-8">
					<div class="clearfix">
						<select id="channel" class="form-control" name='sourceChannelCode' <c:if test="${retype.sourceChannelCode ne null}">disabled="disabled"</c:if> >
							<option class="ch" value=""
								<c:if test="${retype.sourceChannelCode eq null}">selected="selected"</c:if>>请选择</option>
							<c:forEach items="${list_channel}" var="t">
								<option class="ch" value="${t.code}" >${t.name}</option>
							</c:forEach>
						</select>

					</div>
				</div>
			</div>
            <div class="form-group">
				<label class="control-label col-sm-2 no-padding-right" for="sourceTypeName">来源剧情类型</label>
				<div class="col-sm-8">
				<div class="clearfix">
					<input class="form-control" name="sourceTypeName" id="sourceTypeName" type="text"
						value="${retype.sourceTypeName }" <c:if test="${retype.sourceTypeName !=null }">disabled="disabled"</c:if>  placeholder="类型名称" />
                </div>
				</div>
            </div>
            
            
             <div class="form-group">
				<label class="control-label col-sm-2 no-padding-right" for="kind">本地剧情类型</label>
				<div class="col-sm-8">
					<div class="clearfix">
						<select id="kind" class="form-control" name='localTypeCode'>
							<option value=""	<c:if test="${retype.localTypeCode eq null}">selected="selected"</c:if>>请选择</option>
							<%-- <c:forEach items="${}" var="t">			
								<option value="${t.code}"
									<c:if test="${retype.localTypeCode eq t.code}">selected="selected"</c:if> >${t.name}</option>
							</c:forEach> --%>
						</select>
					</div>
					</div>
				</div>
			</div>
             	
              
			
		</form>
		<div class="hr hr-dotted"></div>
	</div>
</div>
<div class="center">
	<button id="btnAdd" type="button" 
	onclick="javascript:$('#retypeForm').submit();" 
	class="btn btn-success btn-sm">
		<i class="fa fa-user-plus"></i>&nbsp;
		<c:if test="${empty retype}">
		添加
		</c:if>
		<c:if test="${!empty retype}">
		保存
		</c:if>
	</button>
	<button id="btn" type="button"
		onclick="webside.common.loadPage('/retype/listUI.html<c:if test="${!empty retype}">?page=${page.pageNum }&rows=${page.pageSize }&sidx=${page.orderByColumn }&sord=${page.orderByType }</c:if>')"
		class="btn btn-info btn-sm">
		<i class="fa fa-undo"></i>&nbsp;返回
	</button>
</div>
<script type="text/javascript">
	/*二级联动  */
	$(function() {
		$("#channel").change(function() {
			var code = $(this).val();
			$.ajax({
                cache: true,
                type: "GET",
                url:"${pageContext.request.contextPath }/retype/getDramaTypes.html?code="+code,
                data:null,
                async: false,
                error: function() {
                    alert("Connection error");
                },
                success: function(data) {
                	var json=eval(data);
   	        	 	var html="";
   	        	 var plDetailStr="<option value='' >请选择</option>";
	   	        	 $.each(json, function (index, item) {  
		                 //循环获取数据    
		                var record =new Object(); 
			                	 record.code=json[index].code;
			                	 record.name=json[index].name; 
			             var retype = "";
		                 plDetailStr+="<option value='"+record.code+"' ";
		                 if(record.code==re){
		                	 plDetailStr+="selected='selected' "
		                 }
		                 plDetailStr+=" >"+record.name+"</option>";
						
		             });
	   	        	html+=plDetailStr;
	   	        	$("#kind").html(html);
                }
            });
		});
		var re = "${retype.localTypeCode}";
		
		if(re!=""){
			s=re.substr(0,re.lastIndexOf("_"));
			$(".ch").each(function(index,data){
				if($(this).val()==s){
					$(this).attr("selected","selected");
					
				}
				$.ajax({
	                cache: true,
	                type: "GET",
	                url:"${pageContext.request.contextPath }/retype/getDramaTypes.html?code="+s,
	                data:null,
	                async: false,
	                error: function() {
	                    alert("Connection error");
	                },
	                success: function(data) {
	                	var json=eval(data);
	   	        	 	var html="";
	   	        	 var plDetailStr="<option value='' >请选择</option>";
		   	        	 $.each(json, function (index, item) {  
			                 //循环获取数据    
			                var record =new Object(); 
				                	 record.code=json[index].code;
				                	 record.name=json[index].name; 
				             var retype = "";
			                 plDetailStr+="<option value='"+record.code+"' ";
			                 if(record.code==re){
			                	 plDetailStr+="selected='selected' "
			                 }
			                 plDetailStr+=" >"+record.name+"</option>";
							
			             });
		   	        	html+=plDetailStr;
		   	        	$("#kind").html(html);
	                }
	            });
			});
		}
		

		
	});
</script>
 